// run: $exec < input
// opt: 0
// flag: -g
#include <iostream>
#include <algorithm>
#include <vector>

long long const maxn = 1000000;
bool not_prime[maxn];
bool has_root[maxn];
long long phi[maxn];
long long n;

void init_phi_and_root()
{
	for (long long i = 1; i < maxn; i++) phi[i] = i;
	has_root[2] = has_root[4] = true;
	for (long long i = 2; i < maxn; i++) {
		if (not_prime[i]) continue;
		phi[i] = i - 1;
		if (i > 2)
			for (long long j = i; j < maxn; j *= i) {
				has_root[j] = true;
				if (2 * j < maxn) has_root[2 * j] = true;
			}
		for (long long j = 2 * i; j < maxn; j += i) {
			not_prime[j] = true;
			phi[j] /= i;
			phi[j] *= i - 1;
		}
	}
}

long long gcd(long long a, long long b)
{
	return !b ? a : gcd(b, a % b);
}

long long quick_pow(long long a, long long b, long long p)
{
	if (!b) return 1;
	long long ret = quick_pow(a, b / 2, p);
	ret = (ret * ret) % p;
	if (b & 1) ret = (ret * a) % p;
	return ret;
}

long long prime_factor[maxn];

long long primitive_root(long long n)
{
	long long p = phi[n], tp = p, size = 0;
	for (long long i = 2; i * i <= tp; i++) {
		if (!(tp % i)) {
			prime_factor[size++] = i;
			while (!(tp % i)) tp /= i;
		}
	}
	if (tp != 1) prime_factor[size++] = tp;

	for (long long i = 1; i < n; i++) {
		if (gcd(i, n) != 1) continue;
		bool is_root = true;
		for (long long j = 0; j < size; j++) {
			long long tmp = prime_factor[j];
			if (quick_pow(i, p / tmp, n) == 1) {
				is_root = false;
				break;
			}
		}
		if (is_root) return i;
	}
	return -1;
}

int main()
{
	std::ios::sync_with_stdio(false);
	init_phi_and_root();
	while (std::cin >> n) {
		if (!has_root[n]) { std::cout << "-1\n"; continue; }
		auto g = primitive_root(n);
		std::vector<long long> ans;
		for (long long i = 1; i <= phi[n]; i++)
			if (gcd(i, phi[n]) == 1) ans.push_back(quick_pow(g, i, n));
		std::sort(ans.begin(), ans.end());
		std::cout << ans[0];
		for (int i = 1; i < (int)ans.size(); i++)
			std::cout << ' ' << ans[i];
		std::cout << '\n';
	}
}

